int s = 400, c = s/2,
cu = 0, dv = 3, colors = 30;

float angle, angle2, m, n, o, p, angle_bis,

core = 0.4,
r_in = 0.6, r_out = 0.95,
a_in = 0.3, a_out = 0.5 * (TWO_PI/dv), // x.x
a_misc = 0.2,

incr;
float[][][] r = new float[dv/2][4][2];

color[] col = new color[colors];
void newcol() { cu += 3; cu %= colors; fill(col[cu]); }
void cir(float f) { ellipse(c, c, s*f, s*f);}
void grey(){fill(0,0,50);}
void setup()
{
    frameRate(10);
    smooth(); noStroke(); colorMode(HSB, 30,100,100);
    for(int i = 0; i < 30; i++) col[i] = color(i,100,100);
    size(400, 400); ellipseMode(CENTER);
    noLoop();
}
void keyPressed()
{
    if(key == 'q') core   += 0.05; if(key == 'w') core   -= 0.05;
    if(key == 'a') a_in   += 0.05; if(key == 's') a_in   -= 0.05;
    if(key == 'z') a_out  += 0.05; if(key == 'x') a_out  -= 0.05;
    if(key == '1') r_in   += 0.05; if(key == '2') r_in   -= 0.05;
    if(key == 'e') a_misc += 0.05; if(key == 'r') a_misc -= 0.05;
    redraw();
}
float theta() { return acos(core/r_out); }
void draw()
{
    background(0,0,100);//background(0,0,80);
    fill(0,0,90);
    for(int i = 0; i < dv; i++)
    {
        angle = float(2*i) * PI/dv;
        m = r_out * c * cos(angle) + c;
        n = r_out * c * sin(angle) + c;
        o = r_in *    c * cos(angle) + c;
        p = r_in *    c * sin(angle) + c;
        arc(c, c, s*r_out, s*r_out, angle, angle + a_out * PI / dv); // outter
        line(m,n,o,p);
    }
    fill(0,0,100);
    noStroke();
    cir(r_in); // cut
    // fill(0,0,90);
    // for(int i = 0; i < dv/2; i++)
    // {
    //     angle = float(2*i) * PI/dv;
    //     m = r_in * c * cos(angle) + c;
    //     n = r_in * c * sin(angle) + c;
    //     o = core * c * cos(angle) + c;
    //     p = core * c * sin(angle) + c;
    //     arc(c,c,s*r_in,s*r_in, angle, angle + a_in*PI/dv);
    //     line(m,n,o,p);        
    // }
    fill(0,0,90);
    cir(core);
    for(int i = 0; i < dv; i++)
    // for(int i = 0; i <1; i++)
    {
        angle = float(2*i) * PI/dv;
        angle2 = theta();
        //rectangles; not ordered to make a correct rectangle
        fill(0,100,100);
        // ellipse(
        //     c * core * cos(angle2 + angle + a_misc *    PI/dv) + c,
        //     c * core * sin(angle2 + angle + a_misc *    PI/dv) + c
        //     ,10,10);

        fill(0,0,90);
        quad(
        c * r_out * cos(angle) + c,
        c * r_out * sin(angle) + c,
        c * r_out * cos(angle + a_misc * PI/dv) + c,
        c * r_out * sin(angle + a_misc * PI/dv) + c,

        c * core * cos(angle2 + angle + a_misc * PI/dv) + c,//there
        c * core * sin(angle2 + angle + a_misc * PI/dv) + c,//there
        c * core * cos(-angle2 + angle) + c,
        c * core * sin(-angle2 + angle) + c
        );

        // quad( r[i][0][0], r[i][0][1], r[i][1][0], r[i][1][1],
        //             r[i][2][0], r[i][2][1], r[i][3][0], r[i][3][1]);

    }
    fill(0,0,90);
    // stroke(0,0,0);
    cir(core);
}
